<template>
   <CardBox title="推荐文章" icon="function/Recommend.png" :refresh="null" v-if="ArticleRecommend && ArticleRecommend.length > 0">
    <div slot="body" class="content">
        <button v-for="(item,index) in ArticleRecommend" :key="index" class="RecomOne" @click="ToArticleDetail(item.id)">
            <!-- 遮罩层 -->
            <div class="shade">
                <img  :src="item.cover" >
            </div>
            <div class="content flex">
                <div class="text flex">
                    <div class="overflow time"><font-awesome-icon icon="clock" /> {{item.createdTime | time }}</div>
                    <div class="overflow">{{item.title}}</div>
                </div>
            </div>
        </button>
    </div>
   </CardBox>
</template>
<script>
import CardBox from '@/components/Package/CardBox/CardBox.vue'
import { mapState } from 'vuex'
  export default 
  {
  components: { CardBox },
     name :'', 
     computed:{
        ...mapState('ArticleDetail',['ArticleDetail','ArticleRecommend'])
     },
     methods:{
         ToArticleDetail(id){
            this.$router.push({path:'/articleDetail', query: {id} })
         }

     },
    
  }
</script>
<style scoped lang='less'>
/* common css */
.icon{  //矢量图标
    width: 25px;
    height: 25px;
    margin-right: 5px;
}
.content{
   width: 100%;
   padding: 10px;
   box-sizing: border-box;
}

.RecomOne{
    width: 100%;
    height: 100px;
    margin-bottom: 10px;
    position: relative;
    border-radius: 5px;
    overflow: hidden;
     
    // 遮罩层
   .shade{
        width: 100%;
        height: 100%;
        position: absolute;
        z-index: 1;
        top: 0;

        img{
              width: 100%;
             height: 100%;
             object-fit: cover;
             transition-duration: 0.5s;
        }
    }
    // 内容
    .content{
         position: relative;
         z-index: 5;
          width: 100%;
          height: 100%;
         background: rgba(0, 0, 0, 0.5);

        .text{
             width: 80%;
             color: white;
             font-size: 18px;
             align-items:baseline;
             div{ 
                width: 100%;
                text-align: center;
            }
            .time{
                font-size: 15px;
                letter-spacing: 0;
                margin-bottom: 5px;
                color: white;
            }
        }
    }

   
}
.RecomOne:hover{

    .content{
         background: none;
    }
    img{
        transform: scale(1.2);
    }
    
}
</style>